package com.bsh.serviceImpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.bsh.dto.AccountNoticeQryDto;
import com.bsh.dto.NoticeRefundQryDto;
import com.bsh.repository.DaoAccountNotice;
import com.bsh.repository.DaoAccountRefund;
import com.bsh.service.AccountNoticeService;
import com.bsh.utils.Pager;

/**
 * 交易明细
 * @author gsh
 *
 */
@Service
@Transactional
public class AccountNoticeServiceImpl implements AccountNoticeService {
	@Autowired
	private DaoAccountNotice accNoticeDao;
	@Autowired
	private DaoAccountRefund accRefundDao;	
	
	/**
	 * 后台管理员充值记录分页
	 */
	@Override
	public List<Map<String, Object>> getRechargeByAdminPage(Pager pager,AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
		
		List<Map<String, Object>> list = accNoticeDao.getRechargeByAdminPage(pager,where.toString());
		return list;
	}	
	
	
	/**
	 * 后台管理员充值记录分页导出
	 */
	@Override
	public List<Map<String, Object>> getRechargeByAdminPageExport(AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
		
		List<Map<String, Object>> list = accNoticeDao.getRechargeByAdminPageExport(where.toString());
		return list;
	}
	
	/**
	 * 会员充值记录分页
	 */
	@Override
	public List<Map<String, Object>> getRechargePage(Pager pager,AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
			if(qryParam.getPaymentId()!=null&& qryParam.getPaymentId()!=-1){
				where.append(String.format(" and a.payment_id=%s ",qryParam.getPaymentId()));
			}
			if(qryParam.getIspay()!=null&& qryParam.getIspay()!=-1){
				where.append(String.format(" and a.is_paid=%s ",qryParam.getIspay()));
			}
		}
		
		List<Map<String, Object>> list = accNoticeDao.getRechargePage(pager,where.toString());
		return list;
	}
	
	/**
	 * 会员充值记录分页_导出
	 */
	@Override
	public List<Map<String, Object>> getRechargePageExport(AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
			if(qryParam.getPaymentId()!=null&& qryParam.getPaymentId()!=-1){
				where.append(String.format(" and a.payment_id=%s ",qryParam.getPaymentId()));
			}
			if(qryParam.getIspay()!=null&& qryParam.getIspay()!=-1){
				where.append(String.format(" and a.is_paid=%s ",qryParam.getIspay()));
			}
		}
		
		List<Map<String, Object>> list = accNoticeDao.getRechargePageExport(where.toString());
		return list;
	}
	
	/**
	 * 提现申请分页
	 */
	@Override
	public List<Map<String, Object>> getCashAskPage(Pager pager,AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(qryParam.getAuditStatus()!=null && qryParam.getAuditStatus()!=-1){
				where.append(String.format(" and a.audit_status=%s ",qryParam.getAuditStatus()));
			}
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
			
		List<Map<String, Object>> list = accRefundDao.getCashPage(pager,where.toString());
		return list;
	}	
	
	/**
	 * 提现申请分页
	 */
	@Override
	public List<Map<String, Object>> getCashAskPageExport(AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(qryParam.getAuditStatus()!=null && qryParam.getAuditStatus()!=-1){
				where.append(String.format(" and a.audit_status=%s ",qryParam.getAuditStatus()));
			}
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
			
		List<Map<String, Object>> list = accRefundDao.getCashPageExport(where.toString());
		return list;
	}
	
	/**
	 * 提现明细分页
	 */
	@Override
	public List<Map<String, Object>> getCashPage(Pager pager,AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
			
		List<Map<String, Object>> list = accNoticeDao.getCashPage(pager,where.toString());
		return list;
	}	
	

	/**
	 * 提现明细分页--导出
	 */
	@Override
	public List<Map<String, Object>> getCashPageExport(AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
			
		List<Map<String, Object>> list = accNoticeDao.getCashPageExport(where.toString());
		return list;
	}
	
	/**
	 * 转帐记录分页
	 */
	@Override
	public List<Map<String, Object>> getTransferPage(Pager pager,AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
			if(qryParam.getPaymentId()!=null&& qryParam.getPaymentId()!=-1){
				where.append(String.format(" and a.payment_id=%s ",qryParam.getPaymentId()));
			}
			if(qryParam.getIspay()!=null&& qryParam.getIspay()!=-1){
				where.append(String.format(" and a.is_paid=%s ",qryParam.getIspay()));
			}
		}
			
		List<Map<String, Object>> list = accNoticeDao.getTransferPage(pager,where.toString());
		return list;
	}	
	
	/**
	 * 转帐记录--导出
	 */
	@Override
	public List<Map<String, Object>> getTransferPageExport(AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
			if(qryParam.getPaymentId()!=null&& qryParam.getPaymentId()!=-1){
				where.append(String.format(" and a.payment_id=%s ",qryParam.getPaymentId()));
			}
			if(qryParam.getIspay()!=null&& qryParam.getIspay()!=-1){
				where.append(String.format(" and a.is_paid=%s ",qryParam.getIspay()));
			}
		}
			
		List<Map<String, Object>> list = accNoticeDao.getTransferPageExport(where.toString());
		return list;
	}	
	
	/**
	 * 升级记录分页
	 */
	@Override
	public List<Map<String, Object>> getUpgradePage(Pager pager,AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
				
		List<Map<String, Object>> list = accNoticeDao.getUpgradePage(pager,where.toString());
		return list;
	}	

	/* (non-Javadoc)
	 * @see com.bsh.serviceImpl.AccountNoticeService#getUpgradePage(com.bsh.utils.Pager, java.lang.String, java.lang.String)
	 */
	@Override
	public List<Map<String, Object>> getBillListMoney(Pager pager,Integer userId) {
		StringBuilder sb =new StringBuilder();
	
		sb.append(" where  a.is_paid = 1 and money is not null and money_type = 1 ");
		sb.append(String.format(" and ( a.userid = '%d'  ) ",userId,userId) );
		
		List<Map<String, Object>> list = accNoticeDao.getBillListMoney(pager,sb.toString());
		return list;
	}


	/* (non-Javadoc)
	 * @see com.bsh.serviceImpl.AccountNoticeService#getUpgradePage(com.bsh.utils.Pager, java.lang.String, java.lang.String)
	 */
	@Override
	public List<Map<String, Object>> getBillListCloud(Pager pager,Integer userId) {
		StringBuilder sb =new StringBuilder();
	
		sb.append(" where  a.is_paid = 1 and money_type = 0 ");
		sb.append(String.format(" and ( a.userid = '%d' ) ",userId,userId) );
		
		List<Map<String, Object>> list = accNoticeDao.getBillListCloud(pager,sb.toString());
		return list;
	}
	
	
	/**
	 * 合作伙伴返币记录分页
	 * 
	 * @param start
	 * @param end
	 * @return
	 */
	@Override
	public List<Map<String, Object>> patnerReturnCloudMoney(Pager pager, AccountNoticeQryDto qryParam){
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
				
		List<Map<String, Object>> list = accNoticeDao.patnerReturnCloudMoney(pager,where.toString());
		return list;		
	}
	
	/**
	 * 合作伙伴返币记录分页 -- 导出
	 * 
	 * @param start
	 * @param end
	 * @return
	 */
	@Override
	public List<Map<String, Object>> patnerReturnCloudMoneyExport(AccountNoticeQryDto qryParam){
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
				
		List<Map<String, Object>> list = accNoticeDao.patnerReturnCloudMoneyExport(where.toString());
		return list;		
	}	
	
	/**
	 * 每日系统返现记录分页
	 * 
	 * @param start
	 * @param end
	 * @return
	 */
	@Override
	public List<Map<String, Object>> sysReturnMoney(Pager pager, AccountNoticeQryDto qryParam){
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
				
		List<Map<String, Object>> list = accNoticeDao.sysReturnMoney(pager,where.toString());
		return list;		
	}


	@Override
	public List<Map<String, Object>> getYestDayMoneyByUserid(Integer userid) {
		return accNoticeDao.getYestDayMoneyByUserid(userid);
	}


	@Override
	public List<Map<String, Object>> getWithdrawlList(Pager pager,Integer userId) {
		StringBuilder sb =new StringBuilder();
		//拼接查询出提现tradetype=3
		sb.append(" and t1.userid = "+userId);
		List<Map<String, Object>> list = accRefundDao.getWithDrawalPage(pager, sb.toString());
		return list;
	}


	@Override
	public List<Map<String, Object>> getSendCloudMoneyList(Pager pager,	AccountNoticeQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
		List<Map<String, Object>> list = accNoticeDao.getSendCloudMoneyList(pager,where.toString());
		return list;		
	}




	@Override
	public List<Map<String, Object>> getNoticeRefundDetail(Pager pager,NoticeRefundQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getTradeType())){
				where.append(String.format(" and a.trade_type = '%s' ",qryParam.getTradeType().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
		List<Map<String, Object>> list = accNoticeDao.getNoticeRefundDetailList(pager,where.toString());
		return list;		
	}


	@Override
	public List<Map<String, Object>> getNoticeRefundDetailExport(
			NoticeRefundQryDto qryParam) {
		StringBuilder where=new StringBuilder();
		if(qryParam!=null){
			if(!StringUtils.isEmpty(qryParam.getUserName())){
				where.append(String.format(" and u.name='%s' ",qryParam.getUserName().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getMobile())){
				where.append(String.format(" and u.mobile like '%%%s%%' ",qryParam.getMobile().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getTradeType())){
				where.append(String.format(" and a.trade_type = '%s' ",qryParam.getTradeType().trim()));
			}
			if(!StringUtils.isEmpty(qryParam.getCreateTime()) && StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time >='%s' ",qryParam.getCreateTime().trim()));
			}else if(StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and a.create_time <='%s 23:59:59' ",qryParam.getCreateTime1().trim()));
			}else if(!StringUtils.isEmpty(qryParam.getCreateTime()) && !StringUtils.isEmpty(qryParam.getCreateTime1())){
				where.append(String.format(" and (a.create_time between '%s' and '%s 23:59:59') ",qryParam.getCreateTime().trim(),qryParam.getCreateTime1().trim()));
			}
		}
		List<Map<String, Object>> list = accNoticeDao.getNoticeRefundDetailListExport(where.toString());
		return list;
	}
}
